<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="<c:url value='/static/jquery/jquery-1.9.1.min.js'/>"
	type="text/javascript"></script>
<script type="text/javascript"
	src="<c:url value='/static/themes/js/jquery.datatables.min.js'/>"></script>
<script type="text/javascript"
	src="<c:url value='/static/datetimepicker/js/bootstrap-datetimepicker.js'/>"
	charset="UTF-8"></script>


<title>审核列表</title>
</head>
<body>
	<div class="panel panel-default bk-bg-white">
		<div class="panel-body">
			<form class="form-horizontal" id="searchform">
				<div class="row">
					<div class="form-group col-sm-4">
						<label class="col-sm-4 control-label">用户生账ID:</label>
						<div class="col-sm-8">
							<input type="text" class="form-control" id="userId"
								name="userId" placeholder="用户生账ID">
						</div>
					</div>

					<div class="form-group col-sm-4">
						<label class="col-sm-4 control-label">审核ID类型:</label>
						<div class="col-sm-8">
							<select id="applicantType" name="applicantType"
								class="form-control">
								<option value="">全部类型</option>
								<option value="1">买手</option>
								<option value="2">商家</option>
							</select>
						</div>
					</div>
					<div class="form-group col-sm-4">
						<label class="col-sm-4 control-label">审核申请类型:</label>
						<div class="col-sm-8">
							<select id="auditTypeId" name="auditTypeId" class="form-control">
								<option value="">全部类型</option>
								<option value="1">用户账户审核</option>
								<option value="2">买手绑定平台账号审核</option>
								<option value="3">商家绑定商铺审核</option>
								<option value="4">买号审核</option>
							</select>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="form-group col-sm-4">
						<label class="col-sm-4 control-label">审核申请类型:</label>
						<div class="col-sm-8">
							<select id="auditStatus" name="auditStatus" class="form-control">
								<option value="">全部状态</option>
								<option value="1" selected="selected">待审核</option>
								<option value="2">通过</option>
								<option value="3">未通过</option>
							</select>
						</div>
					</div>
					<div class="form-group col-sm-4">
						<label class="col-sm-4 control-label">提交申请时间:</label>
						<div class="col-sm-8 input-append date form_datetime2">
							<input class="input-append date form_datetime form-control"
								id="starttime" name="starttime" readonly="readonly"><span
								class="add-on"><i class="icon-remove"></i></span>
						</div>
					</div>
					<div class="form-group col-sm-4">
						<label class="col-sm-1 control-label">-</label>
						<div class="col-sm-8">
							<input class="input-append date form_datetime form-control"
								id="endtime" name="endtime" readonly="readonly"> <span
								class="add-on"><i class="icon-remove"></i></span> <span
								class="add-on"><i class="icon-calendar"></i></span>
						</div>
					</div>
				</div>
				<div class="form-group col-sm-12"
					style="padding-bottom: 15px; text-align: center;">
					<button id="searchButton" type="button"
						class="btn btn-primary glyphicon glyphicon-search">搜索</button>
				</div>
			</form>
		</div>
	</div>
	<!-- panel-body -->
	<!-- panel -->
	<div class="panel panel-default">
		<div class="panel-body">
			<div class="table-responsive">
				<div id="table1_wrapper" class="dataTables_wrapper no-footer">
					<table id="table" class="table dataTable no-footer  table-striped"
						role="grid" aria-describedby="table1_info">
						<thead>
							<tr role="row">
								<th>审核ID类型</th>
								<th>审核申请ID</th>
								<th>审核申请类型</th>
								<th>提交用户生账ID</th>
								<th>审核申请状态</th>
								<th>提交申请时间</th>
								<th>操作</th>
							</tr>
						</thead>
					</table>
				</div>
			</div>
		</div>
	</div>

	<script type="text/javascript">
		$(function($) {
			//日期控件
			$('#starttime').datetimepicker({
				language : 'zh-CN',
				format : 'yyyy-mm-dd hh:ii',
				autoclose : true,
				todayBtn : true,
				minuteStep : 10
			}).on('changeDate', function(ev) {
				var starttime = $(this).val();
				$('#endtime').datetimepicker('setStartDate', starttime);
				$(this).datetimepicker('hide');
			});

			$('#endtime').datetimepicker({
				language : 'zh-CN',
				format : 'yyyy-mm-dd hh:ii',
				autoclose : true,
				todayBtn : true,
				minuteStep : 10
			}).on('changeDate', function(ev) {
				var time = $(this).val();
				$('#starttime').datetimepicker('setEndDate', time);
				$(this).datetimepicker('hide');
			});

			function doSearch() {
				//table展示
				var table = $('#table')
						.DataTable(
								{
									"processing" : true,
									"serverSide" : true,
									"bLengthChange" : false,
									"bFilter" : false,
									"bSort" : false,
									"bDestroy" : true,
									"language" : {
										"url" : path
												+ "/static/language_datatables.json"
									},
									"ajax" : {
										"url" : path + "/audit/auditList",
										"type" : "POST",
										"data" : {
											"userId":$(
											'#userId')
											.val(),
											"auditApplicationId" : $(
													'#auditApplicationId')
													.val(),//审核申请ID
											"applicantType" : $(
													'#applicantType').val(),//审核ID类型
											"auditTypeId" : $('#auditTypeId')
													.val(),//审核申请类型
											"auditStatus" : $('#auditStatus')
													.val(),//审核申请状态
											"starttime" : $('#starttime').val(),
											"endtime" : $('#endtime').val(),
										}
									},
									"oSearch" : {

									},
									"columns" : [ {
										"data" : "applicantType",
										"width" : "10%"
									}, {
										"data" : "auditApplicationId",
										"width" : "10%"
									}, {
										"data" : "auditTypeId",
										"width" : "15%"
									}, {
										"data" : "userId",
										"width" : "15%"
									}, {
										"data" : "auditStatus",
										"width" : "15%"
									}, {
										"data" : "submitTime",
										"width" : "20%"
									}, {
										"data" : "auditAssociationId",
										"width" : "20%"
									} ],
									"columnDefs" : [
											{
												"render" : function(data, type,
														row) {
													return data == 1 ? '买手'
															: '商家';
												},
												"targets" : 0
											},
											{
												"render" : function(data, type,
														row) {
													if (data == 1) {
														return '用户账户审核';
													} else if (data == 2) {
														return '买手绑定平台账号审核';
													} else if (data == 3) {
														return '商家绑定商铺审核';
													} else if (data == 4) {
														return '买号审核';
													}
												},
												"targets" : 2
											},
											{
												"render" : function(data, type,
														row) {
													if (data == 1) {
														return '待审核';
													} else if (data == 2) {
														return '通过审核';
													} else if (data == 3) {
														return '未通过';
													}
												},
												"targets" : 4
											},
											{
												"render" : function(data, type,
														row) {
													return dateTimeFormatter(data);
												},
												"targets" : 5
											},
											{
												"render" : function(data, type,
														row) {
													return '<a class="btn btn-warning" href="'
															+ path
															+ '/audit/detail?id='
															+ row.auditApplicationId
															+ '&type='
															+ row.auditTypeId
															+ '&auditAssociationId='
															+ row.auditAssociationId
															+ '">查看详情</a>';
												},
												"targets" : 6
											} ]

								});
			}
			;
			doSearch();
			//查询事件
			$('#searchButton').click(function() {
				doSearch();
			});
		});
	</script>
</body>
</html>